package com.slz3.business.module.configManagement.conIndexNewGoods.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.configManagement.conIndexNewGoods.domain.ConIndexNewGoods;
import com.slz3.business.module.configManagement.conIndexNewGoods.domain.ConIndexNewGoodsFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class ConIndexNewGoodsTransactionalServiceImpl implements ConIndexNewGoodsTransactionalService {

    @Override
    public ConIndexNewGoods modify(ConIndexNewGoods conIndexNewGoodsNew) {
        Repositorys.conIndexNewGoods.test();
        Repositorys.conIndexNewGoods.save(ConIndexNewGoodsFactory.initBaseFields());
        System.err.println(1/0);
        conIndexNewGoodsNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.conIndexNewGoods.saveAndFlush(conIndexNewGoodsNew);
    }

    @Override
    public List<ConIndexNewGoods> batchModify(List<ConIndexNewGoods> conIndexNewGoodsList) {
        return Repositorys.conIndexNewGoods.saveAll(conIndexNewGoodsList);
    }
}
